<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
    
    <title>对账调整</title>
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <LINK href="<%=root%>/css/caigouxitong.css"" type=text/css rel=stylesheet>      
    <SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
    <SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
    <%
        ArrayList tOrderDeptList = (ArrayList)request.getAttribute("orgware");
        String tRequery = (String)request.getAttribute("requery");
        ArrayList tShipMentList=(ArrayList)request.getAttribute("orgship");
        ResultProcess stocks = (ResultProcess)request.getAttribute("stocks");
        ArrayList stocksList=new ArrayList();
        ArrayList tManuf1 = (ArrayList)request.getAttribute("manufacture1");
        HashMap tMap1 = (HashMap)request.getAttribute("manufacturetyp2");
        HashMap tMap2 = (HashMap)request.getAttribute("manufacturetyp3");
        ArrayList tList1 = new ArrayList();
        String dep=(String) request.getAttribute("deptId");
        if(dep==null){
              dep=request.getParameter("dep");          
        }
        DecimalFormat df = new DecimalFormat("0.0000"); 
    %>
    <script type="text/javascript">
    var counter;
    function change1(optval){
  var val = optval;
  if(val=='0'){
    var listbox = document.getElementById("manuftype2");
    listbox.length = 0;
    var option = new Option();
    option.text = "-----二级-----";
    option.value = "0";
    listbox.options[listbox.length] = option;
    change2(optval);
  }else{
      var counter="0";
    <%if(tMap1 !=null){
      Collection tCollection = tMap1.keySet();
      Iterator tIterator = tCollection.iterator();
      while(tIterator.hasNext()){
        String tKey = (String)tIterator.next();
        tList1 = (ArrayList)tMap1.get(tKey);%>
        if(val == '<%=tKey%>'){
          counter = "1";
          var listbox = document.getElementById("manuftype2");
          listbox.length = 0;
          var option = new Option();
          option.value = "0";
          option.text = "-----二级-----";
          listbox.options[listbox.length] = option;
          <%
                for(int n=0;n<tList1.size();n++){
                    GSManufactureCategoryBean tGSManufactureBean = (GSManufactureCategoryBean)tList1.get(n);
                    String categoryId = tGSManufactureBean.getGs_manufacture_category_id();
                    String categoryName = tGSManufactureBean.getGs_manufacture_category_name();%>
                    var temp1 = '<%=categoryId%>';
                    var temp2 = '<%=categoryName%>';
                    var option = new Option();
                    option.value = temp1;
                    option.text = temp2;
                    listbox.options[listbox.length] = option;
           <%
                }
           %>
            change2('0');           
         }
         
    <%
        }
    %>
        if(counter == '0'){
          var listbox = document.getElementById("manuftype2");
          listbox.length = 0;
          var option = new Option();
          option.value = "0";
          option.text = "-----二级-----";
          listbox.options[listbox.length] = option;  
          change2('0');     
        }
    <%  
    }
    %>
   }
}
    function change2(optval){
      var val = optval;
      if(val=='0'){
        var listbox = document.getElementById("manuftype3");
        listbox.length = 0;
        var option = new Option();
        option.text = "-----三级-----";
        option.value = "0";
        listbox.options[listbox.length] = option;

      }else{
        var counter = "0";
        <%if(tMap2 !=null){
          Collection tCollection = tMap2.keySet();
          Iterator tIterator = tCollection.iterator();
          while(tIterator.hasNext()){
            String tKey = (String)tIterator.next();
            tList1 = (ArrayList)tMap2.get(tKey);%>
            if(val == '<%=tKey%>'){
              counter = "1";
              var listbox = document.getElementById("manuftype3");
              listbox.length = 0;
              var option = new Option();
              option.text = "-----三级-----";
              option.value = "0";
              listbox.options[listbox.length] = option;
              <%for(int n=0;n<tList1.size();n++){
                GSManufactureCategoryBean tGSManufactureBean = (GSManufactureCategoryBean)tList1.get(n);
                String categoryId = tGSManufactureBean.getGs_manufacture_category_id();
                String categoryName = tGSManufactureBean.getGs_manufacture_category_name();%>
                var temp1 = '<%=categoryId%>';
                var temp2 = '<%=categoryName%>';
                var option = new Option();
                option.value = temp1;
                option.text = temp2;
                listbox.options[listbox.length] = option;
                <%}%>
              }
          <%
          }
          %>
          if(counter == '0'){
                var listbox = document.getElementById("manuftype3");
                listbox.length = 0;
                var option = new Option();
                option.text = "-----三级-----";
                option.value = "0";
                listbox.options[listbox.length] = option;          
          }
          <%
            }%>
          }
        }
        
        function selectprovider(){
            var url ="<%=response.encodeURL(request.getContextPath() +"/A401103.do")%>";
            var returnv = window.open(url,null," edge: sunken ,center: Yes, help: No, resizable: Yes, status: No,height=580px, scrollbars=yes");
        }
        function clean(){
            stocksfind.manuftype1.value="0";
            var listbox2 = document.getElementById("manuftype2");
            listbox2.length = 0;
            var option2 = new Option();
            option2.text = "-----二级-----";
            option2.value = "0";            
            listbox2.options[listbox2.length] = option2;
            stocksfind.shipid.value="0000";
            var listbox3 = document.getElementById("manuftype3");
            listbox3.length = 0;
            var option3 = new Option();
            option3.text = "-----三级-----";
            option3.value = "0";            
            listbox3.options[listbox3.length] = option3;
            stocksfind.gs_provider_name.value="";
            stocksfind.providerid.value="";
            stocksfind.stocksid.value="";
            stocksfind.stocksperson.value="";
            stocksfind.stocksmanuname.value="";
            stocksfind.stocksconid.value="";
            stocksfind.stocksdept.value="";
        }
        function process(){
            stocksfind.action="<%=response.encodeURL(request.getContextPath() + "/A181208.do") %>";
            stocksfind.submit();
        }

    </script>
    </head>
    <body BGCOLOR="#f2f2f2" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="<%if(tRequery!=null && tRequery.equals("true")){out.print("process()");}%>">
        <form name="stocksfind" method="get">
            <input type="hidden" name="dep" value="<%=dep%>">
            <p><FONT face="宋体"></FONT><FONT face="宋体"></FONT><br>
            </p>
            <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
                <tr>
                    <td height="20">
                        <table width="100%" border="0" cellspacing="0" cellpadding="1">
                            <tr height="20">
                                <td height="30" width="758" class="mtxt_black">增加应收结算
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td class="bg_line" height="2"></td>
                </tr>
            </table>
            <br>
            <table class="bg_table" id="Table1" style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px" cellSpacing="1"
                cellPadding="0" width="98%" align="center" border="0">
                <tr height="20">
                <TD class="bg_column" align=center>产品种类</TD>
                    <TD class="bg_row_odd" colspan="3">
                        <select name="manuftype1" onChange="change1(this.value)">   
                        <option value="0">-----一级-----</option>             
                        <%
                            String tManufType1 = request.getParameter("manuftype1");
                            if(tManuf1 != null && tManuf1.size() > 0 ){
                                for(int i=0; i<tManuf1.size(); i++){
                                    GSManufactureCategoryBean tGSManufactureBean = (GSManufactureCategoryBean)tManuf1.get(i);
                                    if(tManufType1!=null && tManufType1.equals(tGSManufactureBean.getGs_manufacture_category_id())){
                        %>
                                <option value="<%=tGSManufactureBean.getGs_manufacture_category_id()%>" selected>
                                <%=tGSManufactureBean.getGs_manufacture_category_name()%></option>
                        <%}else{%>
                                <option value="<%=tGSManufactureBean.getGs_manufacture_category_id()%>">
                                <%=tGSManufactureBean.getGs_manufacture_category_name()%></option>
                        <%          }   
                                }
                            }
                        %>
                        </select>
                        <select id="manuftype2" name="manuftype2" onChange="change2(this.value)">   
                        <option value="0">-----二级-----</option>             
                        <%
                            String tManufType2 = request.getParameter("manuftype2");
                            if(tManufType1 != null && !tManufType1.equals("0")){
                                ArrayList temp = (ArrayList)tMap1.get(tManufType1);
                                if(temp!=null){
                                for(int i=0; i<temp.size(); i++){
                                    GSManufactureCategoryBean tGSManuf2 = (GSManufactureCategoryBean)temp.get(i);
                                    if(tManufType2!=null && tManufType2.equals(tGSManuf2.getGs_manufacture_category_id())){
                        %>
                                <option value="<%=tManufType2%>" selected><%=tGSManuf2.getGs_manufacture_category_name()%></option>
                        <%}else{%>
                                <option value="<%=tGSManuf2.getGs_manufacture_category_id()%>"><%=tGSManuf2.getGs_manufacture_category_name()%></option>
                                
                        <%          }   
                                }
                               }
                            }
                        %>

                        </select>
                        <select name="manuftype3" id="manuftype3">  
                        <option value="0">-----三级-----</option>             
                        <%
                            String tManufType3 = request.getParameter("manuftype3");
                            if(tManufType2 != null && !tManufType2.equals("0") ){
                                ArrayList temp = (ArrayList)tMap2.get(tManufType2);
                                if(temp!=null){
                                for(int i=0; i<temp.size(); i++){
                                    GSManufactureCategoryBean tGSManuf3 = (GSManufactureCategoryBean)temp.get(i);
                                    if(tManufType3!=null && tManufType3.equals(tGSManuf3.getGs_manufacture_category_id())){
                        %>
                                <option value="<%=tGSManuf3.getGs_manufacture_category_id()%>" selected><%=tGSManuf3.getGs_manufacture_category_name()%></option>
                        <%}else{%>
                                <option value="<%=tGSManuf3.getGs_manufacture_category_id()%>"><%=tGSManuf3.getGs_manufacture_category_name()%></option>
                                
                        <%          }   
                                }
                              }
                            }
                        %>

                        </select>
                    </TD>
                </tr>
                <TR height="20">
                    <TD class="bg_column" align="center">结算单位</TD>
                    <TD class="bg_row_odd">
                    
                        <select name="orderDeptId" disabled="disabled">                 
                        <option value="0000">---全部---</option>
                        <%
                            String tOrderDept = dep;
                            if(tOrderDeptList != null && tOrderDeptList.size() > 0 ){   
                                if(tOrderDept != null && tOrderDept.equals("0000")){
                                    for(int i=0; i<tOrderDeptList.size(); i++){
                                        GSOrganizationBean temp = (GSOrganizationBean)tOrderDeptList.get(i);
                        %>
                                        <option value="<%=temp.getGs_org_id()%>"><%=temp.getGs_org_name()%></option>                        
                        <%              
                                    }
                                }else{
                                    for(int i=0; i<tOrderDeptList.size(); i++){
                                        GSOrganizationBean temp = (GSOrganizationBean)tOrderDeptList.get(i);
                                        if(tOrderDept != null && tOrderDept.equals(temp.getGs_org_id())){
                            %>
                                            <option value="<%=temp.getGs_org_id()%>" selected><%=temp.getGs_org_name()%></option>
                            <%                  
                                        }else{
                            %>
                                            <option value="<%=temp.getGs_org_id()%>"><%=temp.getGs_org_name()%></option>
                            <%          
                                        }
                                    }
                                }
                            }

                        %>
                        </select>                   

                    </TD>
                    <TD class="bg_column" align="center">供应商</TD>
                    <TD class="bg_row_odd">
                    <input type="text" id='provider_name' name="gs_provider_name" value="<%=request.getParameter("gs_provider_name")== null?"":request.getParameter("gs_provider_name")%>" readonly>
                    <input type="hidden" id='provider_id' name="providerid" value="<%=request.getParameter("providerid")== null?"":request.getParameter("providerid")%>"><input class="kuang" type='button' value='选择供应商' onclick='selectprovider();'></TD>
                </TR>
                <TR height="20">
                <TD class="bg_column" align="center">领用单编号</TD>
                    <TD class="bg_row_odd">
                    <INPUT type="text" name="stocksid" maxlength="20" value="<%=request.getParameter("stocksid")== null?"":request.getParameter("stocksid")%>">
                    </TD>
                    <TD class="bg_column" align="center">领取人</TD>
                    <TD class="bg_row_odd">
                        <input type="text" name="stocksperson" value="<%=request.getParameter("stocksperson")==null?"":request.getParameter("stocksperson")%>">
                    </TD>
                </TR>
                <TR height="20">
                <TD class="bg_column" align="center">产品名称</TD>
                    <TD class="bg_row_odd">
                        <input type="text" name="stocksmanuname" value="<%=request.getParameter("stocksmanuname")==null?"":request.getParameter("stocksmanuname")%>">
                    </TD>
                <TD class="bg_column" align="center">集中编码</TD>
                    <TD class="bg_row_odd">
                    <INPUT type="text" name="stocksconid" maxlength="20" value="<%=request.getParameter("stocksconid")== null?"":request.getParameter("stocksconid")%>">
                    </TD>
                </TR>
                <tr height="20">
                <TD class="bg_column" align="center">审核日期</TD>
                    <TD class="bg_row_odd">
                        <input name="stocksstarttime" type="text"  onfocus="setday(this);" size="12" value="<%=request.getParameter("stocksstarttime")== null?"":request.getParameter("stocksstarttime")%>">~
                        <input name="stocksendtime" type="text"  onfocus="setday(this);" size="12" value="<%=request.getParameter("stocksendtime")== null?"":request.getParameter("stocksendtime")%>">                                           
                    </TD>
                    <TD class="bg_column" align="center">领用部门</TD>
                    <TD class="bg_row_odd">
                    <INPUT type="text" name="stocksdept" maxlength="20" value="<%=request.getParameter("stocksdept")== null?"":request.getParameter("stocksdept")%>">
                    </TD> 
                </tr>
                 <tr height="20">
                <TD class="bg_column" align="center">出货单位</TD>
                    <TD class="bg_row_odd">
                        <select name="shipid" id="shipid">
                        <option value="0000" selected>---全部---</option>
                        <%
                            String shipdept = request.getParameter("shipid");
                            if(tShipMentList != null && tShipMentList.size() > 0 ){   
                                    for(int i=0; i<tShipMentList.size(); i++){
                                        GSOrganizationBean temp = (GSOrganizationBean)tShipMentList.get(i);
                                        if(shipdept != null && shipdept.equals(temp.getGs_org_id())){
                            %>
                                            <option value="<%=temp.getGs_org_id()%>" selected><%=temp.getGs_org_name()%></option>
                            <%                  
                                        }else{
                            %>
                                            <option value="<%=temp.getGs_org_id()%>"><%=temp.getGs_org_name()%></option>
                            <%          
                                        }
                                    }
                                }

                        %>
                        </select>                                           
                    </TD>
                    <TD class="bg_column" align="center">状态</TD>
                    <TD class="bg_row_odd">
                    <select name="stocksstate" id="stocksstate">   
                        <option value="0" selected>未纳入结算</option>
                  </select>
                    </TD>
                    </tr>
            </table>
            <%if(stocks != null){
                int totalRecords = 0;
                if(request.getAttribute("totalRecords")!=null){
                    totalRecords=Integer.parseInt((String)request.getAttribute("totalRecords"));
                }
                int defaultPageSize =10;
                if(request.getAttribute("pageSize")!=null){
                    defaultPageSize=Integer.parseInt((String)request.getAttribute("pageSize"));
                }
            %>          
            <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'></page:pager>
            <%} %>
        </form>
        <p align="center">
            <input type="button" value="查询" class="kuang" onclick="process()">&nbsp;&nbsp;
            <INPUT type="button" value="清空" class="kuang" onclick="clean();">
        </p>

    <center>
    <%if(stocks != null){ %>
    <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
            <td>
            <form name='pager' method="post">
                <table class=bg_table id=tableId    cellspacing=1 cellpadding=2 width=100% align=center border=0>
                    <tbody> 
                    <tr class="bg_column" height=20> 
                        <td class=top align=middle> 
                        <div class="txt_content" align="center">
                        <input type="checkbox" name="ckbox" id="ckbox" onClick="SelectAllCheckBox()"></div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">领用单编号</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">结算单位</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">领取人</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">领取部门</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">商品编号</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">商品名称</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">领用日期</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">供应商</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">单价(元)</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">数量</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">合计(元)</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">录入日期</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">出货单位</div>
                        </td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">结算模式</div>
                        </td>
                    </tr>
                    <%
                        stocksList = stocks.getAllRecoreds();
                        if(stocksList != null && stocksList.size() > 0){
                        for(int i=0; i<stocksList.size(); i++){
                            GSStocksOtherBean sb=(GSStocksOtherBean)stocksList.get(i);
                            String tTempStr="";
                            if(i%2==0){
                                tTempStr="class=\"bg_row_odd\"";
                            }else {
                                tTempStr="class=\"bg_row_even\"";
                            }
                    %>
                            <tr <%=tTempStr%> height=20>
                                <td class=top align=middle> 
                                    <input type=checkbox id='checkboxs<%=i%>' name="check" value="<%=sb.getGs_detail_id()%>">
                                </td>
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <a href="javascript:void(0);" onclick="find('<%=sb.getGs_stocks_id() %>','<%=sb.getGs_detail_id()%>');"><%=sb.getGs_stocks_id()%></a>
                                    </div>
                                </td>
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=sb.getGs_workcorp_name()%>
                                    </div>
                                </td>
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=sb.getGs_stocks_person()%>
                                    </div>
                                </td>   
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=sb.getGs_stocks_dept()%>
                                    </div>
                                </td>                               
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=sb.getGs_manu_id()%>
                                    </div>
                                </td>   
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <a href="<%=response.encodeURL(root+"/A150103.do")%>?concentricityId=<%=sb.getGs_manu_conid()%>"  target="_blank"><%=sb.getGs_manu_name() %></a></div>
                                </td>                           
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=sb.getGs_stocks_date()%>
                                    </div>
                                </td>
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <a href="<%=response.encodeURL(root+"/A150504.do")%>?providerId=<%=sb.getGs_prover_id()%>" target="_blank"><%=sb.getGs_prover_name()%></a>
                                    </div>
                                </td>
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=sb.getGs_detail_price()%>
                                    </div>
                                </td>
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=sb.getGs_detail_count()%>
                                    </div>
                                </td>
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=df.format(sb.getGs_detail_price()*sb.getGs_detail_count())%>
                                    </div>
                                </td>
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=sb.getGs_opertoar_date()%>
                                    </div>
                                </td>
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=sb.getGs_shipment_name()%>
                                    </div>
                                </td>   
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=DefineDic.getBalanceMode(sb.getGs_balance_mode())%>
                                    </div>
                                </td>                                                  
                            </tr> 
                            
                    <%  
                            }
                    %>
                          <tr class="bg_column" height=20>
                            <td width="960" height="16" colspan="15" align="right">
                                    <!--导航条-->
                                    <page:navigator type='text' queryForm="stocksfind"/>
                            </td>
                          
                    <%
                        }else{
                    %>
                            <font color="red">没有符合条件的产品信息</font>
                    <%
                        }
                    %>
                    </tbody>
                </table>
                
                </form>                   
            </td>
        </tr>
    </table>

    </center>
    <center><p>
    <input type="button" class="kuang" width="58" height="24" value="加入结算" onclick="balanceaddno();">&nbsp;
    <input type="button" class="kuang" width="58" height="24" value="关闭" onclick="javascript:window.close();">
    </p></center>
        <%} %>
    <script type="text/javascript">
        function SelectAllCheckBox(){
            var des =document.getElementsByName('check');
                 for(var i=0;i<des.length;i++)
                 {
                    des[i].checked=document.getElementById('ckbox').checked;
                 }
        }
        function balanceaddno(){
            var des =document.getElementsByName('check');
            var a=0;
            for(var i=0;i<des.length;i++)
             {
                if(des[i].checked){
                    a++;
                    var b=des[i].value;
                    opener.location="javascript:addcheck('"+a+"','"+b+"');";
                }
             }
             if(a==0){
                alert("请至少选择一项要加入结算的记录");
                return;
             }
             opener.location="javascript:dosubmit()";
             window.close();
        }
        function find(a,b){
            var rootURL = "<%=response.encodeURL(request.getContextPath()+"/A181107.do")%>?sid="+a+"&did="+b;
            window.open(encodeURI(rootURL),"","height=600,width=950,top=50,left=50,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=yes");
        }
    </script>
</body>
</html>


